package dhm.com.hpx.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;

import java.util.ArrayList;
import java.util.List;

import dhm.com.hpx.R;
import dhm.com.hpx.base.netWork.Constant;
import dhm.com.hpx.entity.MainVideoBean;

/**
 * Created by admin
 * 2019/4/29
 * 所有订单适配器
 */
public class MainVideoAdapter extends RecyclerView.Adapter<MainVideoAdapter.ViewHolder> {

    private Context context;


    List<MainVideoBean.DataBean> list=new ArrayList<>();

    public MainVideoAdapter(Context context) {
        this.context = context;
    }


    public void setList(List<MainVideoBean.DataBean> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        ViewHolder viewHolder;
        View view= LayoutInflater.from(context).inflate(R.layout.recy_radio, null);
        viewHolder=new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int i) {
        viewHolder.image.setImageURI(Constant.PATH+list.get(i).getCoverImg());
        viewHolder.context.setText(list.get(i).getVideo_title());
        viewHolder.watch.setText(list.get(i).getVisitorNum()+"");
        viewHolder.zhuan.setText(list.get(i).getShareNum()+"");
        if (list.get(i).getIsElite()==1){
            viewHolder.like.setImageResource(R.mipmap.likes);
        }else {
            viewHolder.like.setImageResource(R.mipmap.liken);
        }

        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                onClick.item(i);
            }
        });

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        public SimpleDraweeView image;
        public TextView context;
        public TextView watch;
        public TextView zhuan;
        public ImageView like;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            context=itemView.findViewById(R.id.context);
            watch=itemView.findViewById(R.id.watch);
            zhuan=itemView.findViewById(R.id.zhuan);
            like=itemView.findViewById(R.id.like);
            image=itemView.findViewById(R.id.image);
        }
    }

    private OnClick onClick;
    public void setdeleteClick(OnClick onClick) {
        this.onClick = onClick;
    }
    public interface OnClick{
        void item(int posttion);
    }

    private OnIntentClick onIntentClick;
    public void setaddClick(OnIntentClick onClick) {
        this.onIntentClick = onClick;
    }
    public interface OnIntentClick{
        void item();
    }



}

